// pages/salesclerkedit/salesclerkedit.js
var app = getApp();
var com = require('../../common.js');
Page({
  data: {
    id: '',
    status: 0,
    phoneNumber: '',
    password: '',
  },
  onLoad: function(options) {
    var _this = this
    _this.setData({
      id: options.id
    })
  },
  onReady: function() {},
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  onReachBottom: function() {},
  onShareAppMessage: function() {},
  seave() {
    wx.navigateBack({
      delta: 1
    })
  },
  checkChange(e) {
    console.log(e)
    if (e.detail.value.length == 0) {
      this.setData({
        status: 0
      })
    } else {
      this.setData({
        status: 1
      })
    }
  },
  //修改店员信息
  seave() {
    var _this = this,
      id = _this.data.id,
      u = app.link.usersUpdata + wx.getStorageSync('store') + '-' + id + '.st'
    com.link(u, {
      jurisdiction: [],
      state: _this.data.status,
      phoneNumber: _this.data.phoneNumber,
      password: _this.data.password,
    }, function(rep) {
      console.log(rep)
      if (rep.data.state) {
        wx.showToast({
          title: rep.data.message,
          icon:'success'
        })
        setTimeout(()=>{
          wx.navigateBack({
            delta:1
          })
        },1500)
      }
    })
  },
  //获取输入内容  手机号：···   密码：···
  inputBlur(e) {
    var _this = this,
      id = e.currentTarget.id
    if (id == 0) {
      _this.setData({
        phoneNumber: e.detail.value
      })
    } else {
      _this.setData({
        password: e.detail.value
      })
    }
  }
})